/**
 * This exception class catches errors associated with invalid word format or
 * word not found.
 * 
 * @author Yao Wang
 * 
 */
public class WordException extends Exception {
	
	/**
	 * Default UID makes checkstyle happy. 
	 */
	private static final long serialVersionUID = 1L;
	
	/**
	 * Stores error string. 
	 */
	private WordProblem problem;

	
	/**
	 * Constructor that takes a String.
	 * 
	 * @param a
	 *            Error message to be displayed
	 */
		
	public WordException(WordProblem a) {
		problem = a;
	}

	/**
	 * Outputs the error message if an exception is thrown.
	 * 
	 * @return the error message
	 */
	public WordProblem getProblem() {
		return problem;
	}
	
	/**
	 * @return a string descriptor of the problem.
	 */
	public String getOutput() {
		switch (problem) {
		case WrongLength:
			return "Word is of the incorrect length.";
		case DupLetters:
			return "Word contains duplicate letters.";
		case NotOnlyAlpha:
			return "Word contains non-alphabetical characters.";
		case NotInDict:
			return "Word is not contained in the dictionary.";
		default:
			return "";
		}
	}
}
